<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>

<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

//String login_id = null;
String user_id = null;

if(userSession!= null){
	//login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
}

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;


if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
}

String exam_code 		= "";
String exam_num 		= "";
String part_num 		= "";
String cate_code 		= "";
String cont 		= "";
String explane_id 		= "";
String explane_nm 	= "";
String answer_id 	= "";
String answer_nm	= "";
String ready_time 	= "";
String ready_yn	= "";
String response_time 	= "";
String response_yn	= "";
String use_yn	= "";
String answer_cont = "";


if(list != null){
	if(list.size() > 0){
		exam_code = CommonUtil.nvl((String)((HashMap)list.get(0)).get("exam_code"));		
		exam_num = CommonUtil.nvl((String)((HashMap)list.get(0)).get("exam_num"));
		part_num = CommonUtil.nvl((String)((HashMap)list.get(0)).get("part_num"));
		cate_code = CommonUtil.nvl((String)((HashMap)list.get(0)).get("cate_code"));
		cont = CommonUtil.nvl((String)((HashMap)list.get(0)).get("cont"));
		
		explane_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("explane_id"));
		explane_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("explane_nm"));
		answer_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("answer_id"));
		answer_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("answer_nm"));
		ready_time = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ready_time"));
		ready_yn = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ready_yn"));
		response_time = CommonUtil.nvl((String)((HashMap)list.get(0)).get("response_time"));
		response_yn = CommonUtil.nvl((String)((HashMap)list.get(0)).get("response_yn"));
		use_yn = CommonUtil.nvl((String)((HashMap)list.get(0)).get("use_yn"));
		
		answer_cont = CommonUtil.nvl((String)((HashMap)list.get(0)).get("answer_cont"));
		
	}
}


%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/ajaxutil.js"></script>
<script>


function go_input(){
	var frm = document.mainform;	
	
	
	if(frm.exam_num.value==''){
		alert('문제번호를 입력 해주세요');
		frm.exam_num.focus();
		return;
	}
	if(frm.part_num.value==''){
		alert('파트를 입력 해주세요');
		frm.part_num.focus();
		return;
	}
	if(frm.cate_code.value==''){
		alert('카테고리를 선택 해주세요');
		frm.cate_code.focus();
		return;
	}
	
	if(isNaN(frm.exam_num.value)){
		alert('문제번호를  정수로 입력하세요.');
		frm.exam_num.focus();
		return;
	}
	
	if(isNaN(frm.part_num.value)){
		alert('파트를  정수로 입력하세요.');
		frm.part_num.focus();
		return;
	}
	
	if(isNaN(frm.ready_time.value) && frm.ready_time.value!=''){
		alert('준비시간  정수로 입력하세요.');
		frm.ready_time.focus();
		return;
	}
	if(isNaN(frm.response_time.value)  && frm.response_time.value!=''){
		alert('응답시간  정수로 입력하세요.');
		frm.response_time.focus();
		return;
	}
	
	
	frm.action = '/speaking.pb?cmd=prepexam_modify';
	frm.target= 'hidden_frm';              
	frm.submit();	
}


function go_prepexam(){
	
	var frm = document.moveform;	
	frm.cmd.value='prepexam_main';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();
	
}

function go_download(id,name,folder){
	var frm = document.downform;	
	frm.cmd.value='download';
	frm.file_id.value=id;
	frm.file_name.value=name;
	frm.file_folder.value=folder;
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();
}

function init_prepexam(){
	form = document.mainform;
	setSPSelect(form.cate_code_s,'<%=cate_code%>', '카테고리선택', 'prepcate');
    
}

function go_preview(){
	var popleft = (screen.width - 1000)/2;
	var poptop = (screen.height - 300)/2;
	var url="/jsp/sp_sp1102_preview.jsp";
	var open_preview = window.open(url,'preview','width=1000,height=300,resizable=yes,scrollbars=yes,top='+poptop+',left='+popleft);
	open_preview.focus();
}

function go_exam_preview_frm(){
	
	var url="/jsp/sp_sp1102_exam_preview_frm.jsp";
	
	exam_preview.location.href = url;
}

function go_answer_preview_frm(){
	
	var url="/jsp/sp_sp1102_answer_preview_frm.jsp";
	answer_preview.location.href = url;
}

window.onload = init_prepexam;
</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="cate_main" /><jsp:param name="submenu_idx" value="2" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" enctype= "multipart/form-data">
	<div id="bodyContainer">
        <div id="contents">
          <jsp:include page="/jsp/common/submenu_list.jsp"><jsp:param name="submenu_id" value="prepexam_main" /><jsp:param name="submenu_idx" value="3" /></jsp:include>
          
          
          <div class="boxContainer">
            <dl title="Speaking Test Prep  문제  수정">
              <dt>Speaking Test Prep  문제  수정</dt>
            </dl>
            <table class="setupTb">
              <tr>
                <th>카테고리</th>
                <td><select name="cate_code_s" id="cate_code_s" disabled >
                  <option value=''>카테고리</option>                 
                </select></td>
              </tr>
              <input name="cate_code" type="hidden" id="cate_code" value="<%= cate_code%>"/>
             
              <!--  
              <tr>
                <th>파트</th>
                <td><input name="part_num" type="text" id="part_num" style="width:100px" value="<%= part_num%>" readonly/>파트</td>
              </tr>
              -->
              
              <tr>
                <th>문제번호</th>
                <td><input name="exam_num" type="text" id="exam_num" style="width:100px" value="<%=exam_num %>" readonly/>번</td>
              </tr>
              
              <tr>
                <th>지문음성 등록</th>
                <td><input type="file" name="attachFile_1" id="attachFile_1" style="width:200px"/>
                <br><a href="#" onclick="go_download('<%=explane_id %>','<%=explane_nm %>','prepexam')"><%=explane_nm %></a>
                </td>
              </tr>
              
              
              <tr>
                <th>문제내용</th>
                <td><textarea name="cont" rows="5" id="cont" style="width:680px" onkeydown="go_exam_preview_frm()"><%= cont%></textarea>
                <br>
                
                <!-- <a href="#" onclick="go_preview()"><input type="button" value="미리보기" style="width:100px; height:20px" onkeydown="go_exam_preview_frm()"></a>
                 -->
                 
                <b>미리보기</b>
                <br>
                <iframe name='exam_preview'  width='700' height='170' SCROLLING='AUTO' frameborder='0'></iframe>
                <script>go_exam_preview_frm()</script>
                </td>
              </tr>
              
              <tr>
                <th>모범답안음성 등록</th>
                <td><input type="file" name="attachFile_2" id="attachFile_2" style="width:200px"/>
                <br><a href="#" onclick="go_download('<%=answer_id %>','<%=answer_nm %>','prepexam')"><%=answer_nm %></a>
                  </td>
              </tr>
              <tr>
                <th>모범답안내용 등록</th>
                <td><textarea name="answer_cont" rows="5" id="answer_cont" style="width:680px" onkeydown="go_answer_preview_frm()"><%= answer_cont%></textarea>
                <br>
                <b>미리보기</b>
                <br>
                <iframe name='answer_preview'  width='700' height='170' SCROLLING='AUTO' frameborder='0'></iframe>
                <script>go_answer_preview_frm()</script>
                </td>
              </tr>
              
              <tr>
                <th>상태</th>
                <td><input type="radio" name="use_yn" id="use_yn" value="Y" <%=(use_yn.equals("Y"))?"checked":"" %>/><span class="boldText">노출</span><input type="radio" name="use_yn" id="use_yn" value="N"  <%=(use_yn.equals("N"))?"checked":"" %>/><span class="boldText">비노출</span></td>
              </tr>
              
              <!--  
              <tr>
                <th>준비시간 사용</th>
                <td><input type="radio" name="ready_yn" id="ready_yn" value="Y" <%=(ready_yn.equals("Y"))?"checked":"" %>/><span class="boldText">사용</span><input type="radio" name="ready_yn" id="ready_yn" value="N" <%=(ready_yn.equals("N"))?"checked":"" %>/><span class="boldText">사용안함</span></td>
              </tr>
              <tr>
                <th>준비시간</th>
                <td><input name="ready_time" type="text" id="ready_time" style="width:100px" value="<%= ready_time%>"/>초</td>
              </tr>
              
              <tr>
                <th>응답시간 사용</th>
                <td><input type="radio" name="response_yn" id="response_yn" value="Y" <%=(response_yn.equals("Y"))?"checked":"" %>/><span class="boldText">사용</span><input type="radio" name="response_yn" id="response_yn" value="N" <%=(response_yn.equals("N"))?"checked":"" %>/><span class="boldText">사용안함</span></td>
              </tr>
              <tr>
                <th>응답시간</th>
                <td><input name="response_time" type="text" id="response_time" style="width:100px" value="<%=response_time %>"/>초</td>
              </tr>
              -->          
            </table>
            <p><a href="#" onclick="go_input()"><img src="img/btn_regist.gif" alt="등록" width="49" height="20" /></a> <a href="#" onclick="go_prepexam()"><img src="img/btn_list.gif" alt="목록" width="49" height="20" /></a> </p>
            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="exam_code" value="<%=exam_code %>">

<input type="hidden" name="explane_id" value="<%=explane_id %>">
<input type="hidden" name="explane_nm" value="<%=explane_nm %>">

<input type="hidden" name="answer_id" value="<%=answer_id %>">
<input type="hidden" name="answer_nm" value="<%=answer_nm %>">

</form>

<form name="moveform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="cate_code" value="<%=cate_code %>">

</form>

<form name="downform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="cmd" value="">
<input type="hidden" name="file_id" >
<input type="hidden" name="file_name" >
<input type="hidden" name="file_folder" >
</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
